/*
 * @Description: 发布中心
 * @Author: iamsmiling
 * @Date: 2021-06-05 18:10:44
 * @LastEditTime: 2021-06-15 14:46:21
 */

import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/pages/publish_square/children/publish_center/publish_center_controller.dart';
import 'package:credit_business_circle/pages/publish_square/children/publish_center/section/source_description_form_card.dart';
import 'package:credit_business_circle/routes/app_routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:credit_business_circle/domain/local/publish/publish_category_entity.dart';

import 'section/brand_form_card.dart';
import 'section/identity_form_card.dart';
import 'section/platform_form_card.dart';
import 'section/source_demander_form_card.dart';
import 'section/source_provider_form_card.dart';

class PublishCenterPage extends GetView<PublishCenterController> {
  const PublishCenterPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: R.color.fff5f5f5,
      appBar: AppBar(
        title: Text(controller.publishType.title),
      ),
      body: GetBuilder<PublishCenterController>(builder: (_) {
        return Column(
          children: [
            Visibility(
              visible: _.showTip,
              child: Stack(
                children: [
                  Container(
                    padding: EdgeInsets.only(
                        top: R.dimen.dp16,
                        left: R.dimen.dp15,
                        bottom: R.dimen.dp15,
                        right: R.dimen.dp20),
                    alignment: Alignment.centerLeft,
                    width: R.dimen.width,
                    // height: R.dimen.dp60,
                    key: ValueKey("TipItem"),
                    decoration: BoxDecoration(color: R.color.ffd4faed),
                    child: Text(
                      "严禁发布各类违法、违禁信息；\n发布的信息及图片中不可带有任何联系方式，否则将予冻结账号处罚！",
                      style: TextStyle(
                          fontSize: R.dimen.sp11, color: R.color.ff111111),
                    ),
                  ),
                  Positioned(
                      top: R.dimen.dp10,
                      right: R.dimen.dp10,
                      child: GestureDetector(
                          onTap: _.close, child: Image.asset(R.image.closeTip)))
                ],
              ),
            ),
            Expanded(
                child: Form(
                    child: ListView(
              children: [
                BrandFormCard(controller: _),
                PlatFormFormCard(controller: _),
                SourceProviderFormCard(),
                SourceDemanderFormCard(),
                SoureceDescriptionFormCard(),
                IdentityFormCard(),
              ],
            )))
          ],
        );
      }),
      bottomNavigationBar: Container(
        margin: EdgeInsets.only(bottom: Get.mediaQuery.padding.bottom),
        padding: EdgeInsets.symmetric(horizontal: R.dimen.dp10),
        child: ElevatedButtonTheme(
          data: ElevatedButtonThemeData(
              style: ButtonStyle(
                  textStyle: MaterialStateProperty.all(
                      TextStyle(fontSize: R.dimen.sp15)),
                  padding: MaterialStateProperty.all(
                      EdgeInsets.symmetric(vertical: R.dimen.dp13)),
                  elevation: MaterialStateProperty.all(0),
                  overlayColor: MaterialStateProperty.all(R.color.transparent),
                  shape: MaterialStateProperty.all(RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(R.dimen.sp5))),
                  foregroundColor: MaterialStateProperty.all(Colors.white),
                  backgroundColor: MaterialStateProperty.all(R.color.ff36ba93),
                  minimumSize: MaterialStateProperty.all(
                      Size(R.dimen.width, R.dimen.dp40)))),
          child: Row(
            children: [
              Expanded(
                  child: ElevatedButton(
                      onPressed: () => Get.toNamed(
                          Get.currentRoute + AppRoutes.publishSuccess),
                      child: Text("预览"))),
              SizedBox(
                width: R.dimen.dp20,
              ),
              Expanded(
                  child: ElevatedButton(
                      onPressed: controller.publish, child: Text("发布")))
              // Container(
              //     margin: EdgeInsets.only(left: R.dimen.dp10),
              //     decoration: BoxDecoration(color: R.color.ff16c692),
              //     child: Text("预览")),
              // Container(
              //     margin: EdgeInsets.only(left: R.dimen.dp10),
              //     decoration: BoxDecoration(color: R.color.ff16c692),
              //     child: Text("发布")),
            ],
          ),
        ),
      ),
    );
  }
}
